package com.sth.test1;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.write.metadata.style.WriteCellStyle;
import com.alibaba.excel.write.metadata.style.WriteFont;
import com.alibaba.excel.write.style.HorizontalCellStyleStrategy;
import com.sth.domain.ItemResultEntity;
import com.sth.domain.TestResultEntity;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;

import javax.swing.*;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * @Author: sitianhong
 * @Description:
 * @Since: create in 2021/11/29 0029 15:58
 */
@Slf4j
public class Processor1 {
    static List<TestResultEntity> allList = new ArrayList<>();

    static List<String> keywordList = Arrays.asList("VDD_HC", "IDDQ of CORE_PLL_DVDD", "IDDQ of DDR_PLL_DVDD", "IDDQ of HT0_PLL_DVDD", "IDDQ of HT1_PLL_DVDD", "IDDQ of VDDESB", "IDDQ of VDDE_1V2",
                                                    "IDDQ of VDDE_1V8", "IDDQ of VDDE_3V3", "IDDQ of VDD_MEM", "IDDQ of VDDE_DDR", "CLKSEL00", "HT0_8x2", "HT0CLKn", "MC0_DDR2_CB0", "GPIO00",
                                                    "LPC_LAD0", "PCI_AD04", "SPI_SDO", "UART0_TXD", "UART1_TXD", "MC0_DDR2_DQ00", "MC1_DDR2_DQ00", "MC0_DDR2_DQSp0", "MC1_DDR2_DQSp0", "MC0_DDR2_CKp0",
                                                    "MC1_DDR2_CKp0", "MC0_DDR2_A00", "MC1_DDR2_A00");

    static String unitRule = "\\d+";
    static String valueRule = "[a-zA-Z]";

    public static void getFilePath(String filePath, String excelName) throws IOException {
        String rootFile = filePath;
        File root = new File(rootFile);
        File[] subFiles = root.listFiles();

        List<String> fileNameList = new LinkedList<>();
        for (File f : subFiles) {
            fileNameList.add(f.getName());
        }

        fileNameList.stream().forEach(item -> {
            readText(filePath + "\\" + item, item);
        });

        // 写入excel
        excelData(allList, filePath, excelName);
    }

    private static void readText(String filePath, String fileName) {
        List<String> efficientDataList = new ArrayList<>();

        // 数据收集
        FileInputStream fis = null;
        InputStreamReader isr = null;
        BufferedReader br = null;
        try {
            String str = "";
            fis = new FileInputStream(filePath);
            isr = new InputStreamReader(fis);
            br = new BufferedReader(isr);
            while ((str = br.readLine()) != null) {
                for (String item : keywordList) {
                    if (StringUtils.contains(str, item)) {
                        efficientDataList.add(str);
                        break;
                    }
                }
            }
            processData(efficientDataList, fileName);// 数据处理和存储
        } catch (Exception e) {
            System.out.println("找不到指定文件" + e);
        } finally {
            try {
                br.close();
                isr.close();
                fis.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    private static void excelData(List<TestResultEntity> allList, String filePath, String excelName) throws IOException {
        String fileName = filePath + "\\" + excelName + ".xlsx";
        File testFile = new File(fileName);
        if (!testFile.exists()) {
            testFile.createNewFile();// 能创建多级目录
        }
        // 已经采集成功了
        try {
            // 头的策略
            WriteCellStyle headWriteCellStyle = new WriteCellStyle();
            WriteFont headWriteFont = new WriteFont();
            headWriteFont.setFontHeightInPoints((short) 10);
            headWriteCellStyle.setWriteFont(headWriteFont);
            // 内容的策略
            WriteCellStyle contentWriteCellStyle = new WriteCellStyle();
            WriteFont contentWriteFont = new WriteFont();
            // 字体大小
            contentWriteFont.setFontHeightInPoints((short) 40);
            contentWriteCellStyle.setWriteFont(contentWriteFont);
            // 这个策略是 头是头的样式 内容是内容的样式 其他的策略可以自己实现
            HorizontalCellStyleStrategy horizontalCellStyleStrategy = new HorizontalCellStyleStrategy(headWriteCellStyle, contentWriteCellStyle);
            // 创建文件
            EasyExcel.write(fileName).registerWriteHandler(horizontalCellStyleStrategy).sheet("文件采集数据").doWrite(dataList(allList));
        } catch (Exception e) {
            System.out.println("error-----生成Excel失败!" + e);
        }

    }

    private static List dataList(List<TestResultEntity> allList) {
        List<List<String>> list = new ArrayList<List<String>>();
        allList.stream().forEach(item -> {
            // 没一行数据
            LinkedHashMap<String, LinkedList<ItemResultEntity>> testLineData = item.getTestData();
            testLineData.forEach((k, v) -> {
                List<String> data = new ArrayList<String>();
                data.add(k);// 文件名字
                // 文件数据
                LinkedList<ItemResultEntity> testLineListData = (LinkedList<ItemResultEntity>) v;
                testLineListData.stream().forEach(testItem -> {
                    testItem.getTestName();
                    data.add(testItem.getTestName());
                    data.add(testItem.getTestValue());
                    if (testItem.getTestUnit() != null) {
                        data.add(testItem.getTestUnit());
                    }
                });
                list.add(data);
            });
        });
        return list;
    }

    private static void processData(List<String> efficientDataList, String fileName) {
        //数据处理

        LinkedHashMap<String, String> hashMap = new LinkedHashMap<>();// 第一部分,要去重 11 个
        LinkedList<ItemResultEntity> itemResultEntities = new LinkedList<>();// 第二部分,不去重28 +9=37
        efficientDataList.stream().forEach(s1 -> {

            String item = s1.replaceAll("\\s{1,}", " ");
            //  System.out.println("itme----->" + item);
            if (StringUtils.contains(item, "VDD_HC")) {
                String[] s = item.split(" ");
                hashMap.put("VDD_HC", s[2]);
            } else if (StringUtils.contains(item, "IDDQ of CORE_PLL_DVDD")) {
                String[] s = item.split(" ");
                hashMap.put("IDDQ of CORE_PLL_DVDD", s[4]);
            } else if (StringUtils.contains(item, "IDDQ of DDR_PLL_DVDD")) {
                String[] s = item.split(" ");
                hashMap.put("IDDQ of DDR_PLL_DVDD", s[4]);
            } else if (StringUtils.contains(item, "IDDQ of HT0_PLL_DVDD")) {
                String[] s = item.split(" ");
                hashMap.put("IDDQ of HT0_PLL_DVDD", s[4]);
            } else if (StringUtils.contains(item, "IDDQ of HT1_PLL_DVDD")) {
                String[] s = item.split(" ");
                hashMap.put("IDDQ of HT1_PLL_DVDD", s[4]);
            } else if (StringUtils.contains(item, "IDDQ of VDDESB")) {
                String[] s = item.split(" ");
                hashMap.put("IDDQ of VDDESB", s[4]);
            } else if (StringUtils.contains(item, "IDDQ of VDDE_1V2")) {
                String[] s = item.split(" ");
                hashMap.put("IDDQ of VDDE_1V2", s[4]);
            } else if (StringUtils.contains(item, "IDDQ of VDDE_1V8")) {
                String[] s = item.split(" ");
                hashMap.put("IDDQ of VDDE_1V8", s[4]);
            } else if (StringUtils.contains(item, "IDDQ of VDDE_3V3")) {
                String[] s = item.split(" ");
                hashMap.put("IDDQ of VDDE_3V3", s[4]);
            } else if (StringUtils.contains(item, "IDDQ of VDD_MEM")) {
                String[] s = item.split(" ");
                hashMap.put("IDDQ of VDD_MEM", s[4]);
            } else if (StringUtils.contains(item, "IDDQ of VDDE_DDR")) {
                String[] s = item.split(" ");
                hashMap.put("IDDQ of VDDE_DDR", s[4]);//  开始需要重复数据 2  ---> +2   共 9个 有重复的  + 28 个有单位的
            } else if (StringUtils.contains(item, "CLKSEL00") && !StringUtils.contains(item, "TIME")) {
                String[] s = item.split(" "); //
                ItemResultEntity itemResultEntity = new ItemResultEntity();
                itemResultEntity.setTestName("CLKSEL00");
                itemResultEntity.setTestValue(s[5]);
                itemResultEntities.add(itemResultEntity); //2
            } else if (StringUtils.contains(item, "HT0_8x2") && !StringUtils.contains(item, "TIME")) {
                String[] s = item.split(" ");
                ItemResultEntity itemResultEntity = new ItemResultEntity();
                itemResultEntity.setTestName("HT0_8x2");
                itemResultEntity.setTestValue(s[5]);
                itemResultEntities.add(itemResultEntity); // 1
            } else if (StringUtils.contains(item, "HT0CLKn") && !StringUtils.contains(item, "TIME")) {
                String[] s = item.split(" ");
                ItemResultEntity itemResultEntity = new ItemResultEntity();
                itemResultEntity.setTestName("HT0CLKn");
                itemResultEntity.setTestValue(s[5]);
                itemResultEntities.add(itemResultEntity); //2
            } else if (StringUtils.contains(item, "MC0_DDR2_CB0") && !StringUtils.contains(item, "TIME")) {
                String[] s = item.split(" ");
                ItemResultEntity itemResultEntity = new ItemResultEntity();
                itemResultEntity.setTestName("MC0_DDR2_CB0");
                itemResultEntity.setTestValue(s[5]);
                itemResultEntities.add(itemResultEntity); // 1
            } else if (StringUtils.contains(item, "GPIO00") && !StringUtils.contains(item, "TIME") && !StringUtils.contains(item, "#devices")) {
                String[] s = item.split(" ");
                ItemResultEntity itemResultEntity = new ItemResultEntity();
                itemResultEntity.setTestName("GPIO00");
                itemResultEntity.setTestValue(s[5]);
                itemResultEntities.add(itemResultEntity); // 1
            }
            //------------------------------------------------带单位
            else if (StringUtils.contains(item, "LPC_LAD0") && StringUtils.contains(item, "TIME")) {
                String[] s = item.split("TIME");
                ItemResultEntity itemResultEntity = new ItemResultEntity();
                itemResultEntity.setTestName("LPC_LAD0");
                String valueAndUnit = s[1].trim();
                String unit = valueAndUnit.replaceAll(unitRule, "");
                String value = valueAndUnit.replaceAll(valueRule, "");
                itemResultEntity.setTestValue(value);
                itemResultEntity.setTestUnit(unit);
                itemResultEntities.add(itemResultEntity);
            } else if (StringUtils.contains(item, "PCI_AD04") && StringUtils.contains(item, "TIME")) {
                String[] s = item.split("TIME");
                ItemResultEntity itemResultEntity = new ItemResultEntity();
                itemResultEntity.setTestName("PCI_AD04");
                String valueAndUnit = s[1].trim();
                String unit = valueAndUnit.replaceAll(unitRule, "");
                String value = valueAndUnit.replaceAll(valueRule, "");
                itemResultEntity.setTestValue(value);
                itemResultEntity.setTestUnit(unit);
                itemResultEntities.add(itemResultEntity);
            } else if (StringUtils.contains(item, "SPI_SDO") && StringUtils.contains(item, "TIME")) {
                String[] s = item.split("TIME");
                ItemResultEntity itemResultEntity = new ItemResultEntity();
                itemResultEntity.setTestName("SPI_SDO");
                String valueAndUnit = s[1].trim();
                String unit = valueAndUnit.replaceAll(unitRule, "");
                String value = valueAndUnit.replaceAll(valueRule, "");
                itemResultEntity.setTestValue(value);
                itemResultEntity.setTestUnit(unit);
                itemResultEntities.add(itemResultEntity);
            } else if (StringUtils.contains(item, "GPIO00") && StringUtils.contains(item, "TIME")) {
                String[] s = item.split("TIME");
                ItemResultEntity itemResultEntity = new ItemResultEntity();
                itemResultEntity.setTestName("GPIO00");
                String valueAndUnit = s[1].trim();
                String unit = valueAndUnit.replaceAll(unitRule, "");
                String value = valueAndUnit.replaceAll(valueRule, "");
                itemResultEntity.setTestValue(value);
                itemResultEntity.setTestUnit(unit);
                itemResultEntities.add(itemResultEntity);
            } else if (StringUtils.contains(item, "UART0_TXD") && StringUtils.contains(item, "TIME")) {
                String[] s = item.split("TIME");
                ItemResultEntity itemResultEntity = new ItemResultEntity();
                itemResultEntity.setTestName("UART0_TXD");
                String valueAndUnit = s[1].trim();
                String unit = valueAndUnit.replaceAll(unitRule, "");
                String value = valueAndUnit.replaceAll(valueRule, "");
                itemResultEntity.setTestValue(value);
                itemResultEntity.setTestUnit(unit);
                itemResultEntities.add(itemResultEntity);
            } else if (StringUtils.contains(item, "UART1_TXD") && StringUtils.contains(item, "TIME")) {
                String[] s = item.split("TIME");
                ItemResultEntity itemResultEntity = new ItemResultEntity();
                itemResultEntity.setTestName("UART1_TXD");
                String valueAndUnit = s[1].trim();
                String unit = valueAndUnit.replaceAll(unitRule, "");
                String value = valueAndUnit.replaceAll(valueRule, "");
                itemResultEntity.setTestValue(value);
                itemResultEntity.setTestUnit(unit);
                itemResultEntities.add(itemResultEntity);
            } else if (StringUtils.contains(item, "MC0_DDR2_DQ00") && StringUtils.contains(item, "TIME")) {
                String[] s = item.split("TIME");
                ItemResultEntity itemResultEntity = new ItemResultEntity();
                itemResultEntity.setTestName("MC0_DDR2_DQ00");
                String valueAndUnit = s[1].trim();
                String unit = valueAndUnit.replaceAll(unitRule, "");
                String value = valueAndUnit.replaceAll(valueRule, "");
                itemResultEntity.setTestValue(value);
                itemResultEntity.setTestUnit(unit);
                itemResultEntities.add(itemResultEntity);
            } else if (StringUtils.contains(item, "MC1_DDR2_DQ00") && StringUtils.contains(item, "TIME")) {
                String[] s = item.split("TIME");
                ItemResultEntity itemResultEntity = new ItemResultEntity();
                itemResultEntity.setTestName("MC1_DDR2_DQ00");
                String valueAndUnit = s[1].trim();
                String unit = valueAndUnit.replaceAll(unitRule, "");
                String value = valueAndUnit.replaceAll(valueRule, "");
                itemResultEntity.setTestValue(value);
                itemResultEntity.setTestUnit(unit);
                itemResultEntities.add(itemResultEntity);
            } else if (StringUtils.contains(item, "MC0_DDR2_DQSp0") && StringUtils.contains(item, "TIME")) {
                String[] s = item.split("TIME");
                ItemResultEntity itemResultEntity = new ItemResultEntity();
                itemResultEntity.setTestName("MC0_DDR2_DQSp0");
                String valueAndUnit = s[1].trim();
                String unit = valueAndUnit.replaceAll(unitRule, "");
                String value = valueAndUnit.replaceAll(valueRule, "");
                itemResultEntity.setTestValue(value);
                itemResultEntity.setTestUnit(unit);
                itemResultEntities.add(itemResultEntity);
            } else if (StringUtils.contains(item, "MC1_DDR2_DQSp0") && StringUtils.contains(item, "TIME")) {
                String[] s = item.split("TIME");
                ItemResultEntity itemResultEntity = new ItemResultEntity();
                itemResultEntity.setTestName("MC1_DDR2_DQSp0");
                String valueAndUnit = s[1].trim();
                String unit = valueAndUnit.replaceAll(unitRule, "");
                String value = valueAndUnit.replaceAll(valueRule, "");
                itemResultEntity.setTestValue(value);
                itemResultEntity.setTestUnit(unit);
                itemResultEntities.add(itemResultEntity);
            } else if (StringUtils.contains(item, "MC0_DDR2_CKp0") && StringUtils.contains(item, "TIME")) {
                String[] s = item.split("TIME");
                ItemResultEntity itemResultEntity = new ItemResultEntity();
                itemResultEntity.setTestName("MC0_DDR2_CKp0");
                String valueAndUnit = s[1].trim();
                String unit = valueAndUnit.replaceAll(unitRule, "");
                String value = valueAndUnit.replaceAll(valueRule, "");
                itemResultEntity.setTestValue(value);
                itemResultEntity.setTestUnit(unit);
                itemResultEntities.add(itemResultEntity);
            } else if (StringUtils.contains(item, "MC1_DDR2_CKp0") && StringUtils.contains(item, "TIME")) {
                String[] s = item.split("TIME");
                ItemResultEntity itemResultEntity = new ItemResultEntity();
                itemResultEntity.setTestName("MC1_DDR2_CKp0");
                String valueAndUnit = s[1].trim();
                String unit = valueAndUnit.replaceAll(unitRule, "");
                String value = valueAndUnit.replaceAll(valueRule, "");
                itemResultEntity.setTestValue(value);
                itemResultEntity.setTestUnit(unit);
                itemResultEntities.add(itemResultEntity);
            } else if (StringUtils.contains(item, "MC0_DDR2_A00") && StringUtils.contains(item, "TIME")) {
                String[] s = item.split("TIME");
                ItemResultEntity itemResultEntity = new ItemResultEntity();
                itemResultEntity.setTestName("MC0_DDR2_A00");
                String valueAndUnit = s[1].trim();
                String unit = valueAndUnit.replaceAll(unitRule, "");
                String value = valueAndUnit.replaceAll(valueRule, "");
                itemResultEntity.setTestValue(value);
                itemResultEntity.setTestUnit(unit);
                itemResultEntities.add(itemResultEntity);
            } else if (StringUtils.contains(item, "MC1_DDR2_A00") && StringUtils.contains(item, "TIME")) {
                String[] s = item.split("TIME");
                ItemResultEntity itemResultEntity = new ItemResultEntity();
                itemResultEntity.setTestName("MC1_DDR2_A00");
                String valueAndUnit = s[1].trim();
                String unit = valueAndUnit.replaceAll(unitRule, "");
                String value = valueAndUnit.replaceAll(valueRule, "");
                itemResultEntity.setTestValue(value);
                itemResultEntity.setTestUnit(unit);
                itemResultEntities.add(itemResultEntity);
            } else if (StringUtils.contains(item, "PCI_AD04") && StringUtils.contains(item, "TIME")) {
                String[] s = item.split("TIME");
                ItemResultEntity itemResultEntity = new ItemResultEntity();
                itemResultEntity.setTestName("PCI_AD04");
                String valueAndUnit = s[1].trim();
                String unit = valueAndUnit.replaceAll(unitRule, "");
                String value = valueAndUnit.replaceAll(valueRule, "");
                itemResultEntity.setTestValue(value);
                itemResultEntity.setTestUnit(unit);
                itemResultEntities.add(itemResultEntity);
            } else if (StringUtils.contains(item, "SPI_SDO") && StringUtils.contains(item, "TIME")) {
                String[] s = item.split("TIME");
                ItemResultEntity itemResultEntity = new ItemResultEntity();
                itemResultEntity.setTestName("SPI_SDO");
                String valueAndUnit = s[1].trim();
                String unit = valueAndUnit.replaceAll(unitRule, "");
                String value = valueAndUnit.replaceAll(valueRule, "");
                itemResultEntity.setTestValue(value);
                itemResultEntity.setTestUnit(unit);
                itemResultEntities.add(itemResultEntity);
            } else if (StringUtils.contains(item, "UART0_TXD") && StringUtils.contains(item, "TIME")) {
                String[] s = item.split("TIME");
                ItemResultEntity itemResultEntity = new ItemResultEntity();
                itemResultEntity.setTestName("UART0_TXD");
                String valueAndUnit = s[1].trim();
                String unit = valueAndUnit.replaceAll(unitRule, "");
                String value = valueAndUnit.replaceAll(valueRule, "");
                itemResultEntity.setTestValue(value);
                itemResultEntity.setTestUnit(unit);
                itemResultEntities.add(itemResultEntity);
            } else if (StringUtils.contains(item, "UART1_TXD") && StringUtils.contains(item, "TIME")) {
                String[] s = item.split("TIME");
                ItemResultEntity itemResultEntity = new ItemResultEntity();
                itemResultEntity.setTestName("UART1_TXD");
                String valueAndUnit = s[1].trim();
                String unit = valueAndUnit.replaceAll(unitRule, "");
                String value = valueAndUnit.replaceAll(valueRule, "");
                itemResultEntity.setTestValue(value);
                itemResultEntity.setTestUnit(unit);
                itemResultEntities.add(itemResultEntity);
            } else if (StringUtils.contains(item, "MC0_DDR2_DQ00") && StringUtils.contains(item, "TIME")) {
                String[] s = item.split("TIME");
                ItemResultEntity itemResultEntity = new ItemResultEntity();
                itemResultEntity.setTestName("MC0_DDR2_DQ00");
                String valueAndUnit = s[1].trim();
                String unit = valueAndUnit.replaceAll(unitRule, "");
                String value = valueAndUnit.replaceAll(valueRule, "");
                itemResultEntity.setTestValue(value);
                itemResultEntity.setTestUnit(unit);
                itemResultEntities.add(itemResultEntity);
            } else if (StringUtils.contains(item, "MC1_DDR2_DQ00") && StringUtils.contains(item, "TIME")) {
                String[] s = item.split("TIME");
                ItemResultEntity itemResultEntity = new ItemResultEntity();
                itemResultEntity.setTestName("MC1_DDR2_DQ00");
                String valueAndUnit = s[1].trim();
                String unit = valueAndUnit.replaceAll(unitRule, "");
                String value = valueAndUnit.replaceAll(valueRule, "");
                itemResultEntity.setTestValue(value);
                itemResultEntity.setTestUnit(unit);
                itemResultEntities.add(itemResultEntity);
            } else if (StringUtils.contains(item, "MC0_DDR2_DQSp0") && StringUtils.contains(item, "TIME")) {
                String[] s = item.split("TIME");
                ItemResultEntity itemResultEntity = new ItemResultEntity();
                itemResultEntity.setTestName("MC0_DDR2_DQSp0");
                String valueAndUnit = s[1].trim();
                String unit = valueAndUnit.replaceAll(unitRule, "");
                String value = valueAndUnit.replaceAll(valueRule, "");
                itemResultEntity.setTestValue(value);
                itemResultEntity.setTestUnit(unit);
                itemResultEntities.add(itemResultEntity);
            } else if (StringUtils.contains(item, "MC1_DDR2_DQSp0") && StringUtils.contains(item, "TIME")) {
                String[] s = item.split("TIME");
                ItemResultEntity itemResultEntity = new ItemResultEntity();
                itemResultEntity.setTestName("MC1_DDR2_DQSp0");
                String valueAndUnit = s[1].trim();
                String unit = valueAndUnit.replaceAll(unitRule, "");
                String value = valueAndUnit.replaceAll(valueRule, "");
                itemResultEntity.setTestValue(value);
                itemResultEntity.setTestUnit(unit);
                itemResultEntities.add(itemResultEntity);
            } else if (StringUtils.contains(item, "MC0_DDR2_CKp0") && StringUtils.contains(item, "TIME")) {
                String[] s = item.split("TIME");
                ItemResultEntity itemResultEntity = new ItemResultEntity();
                itemResultEntity.setTestName("MC0_DDR2_CKp0");
                String valueAndUnit = s[1].trim();
                String unit = valueAndUnit.replaceAll(unitRule, "");
                String value = valueAndUnit.replaceAll(valueRule, "");
                itemResultEntity.setTestValue(value);
                itemResultEntity.setTestUnit(unit);
                itemResultEntities.add(itemResultEntity);
            } else if (StringUtils.contains(item, "MC1_DDR2_CKp0") && StringUtils.contains(item, "TIME")) {
                String[] s = item.split("TIME");
                ItemResultEntity itemResultEntity = new ItemResultEntity();
                itemResultEntity.setTestName("MC1_DDR2_CKp0");
                String valueAndUnit = s[1].trim();
                String unit = valueAndUnit.replaceAll(unitRule, "");
                String value = valueAndUnit.replaceAll(valueRule, "");
                itemResultEntity.setTestValue(value);
                itemResultEntity.setTestUnit(unit);
                itemResultEntities.add(itemResultEntity);
            } else if (StringUtils.contains(item, "MC1_DDR2_A00") && StringUtils.contains(item, "TIME")) {
                String[] s = item.split("TIME");
                ItemResultEntity itemResultEntity = new ItemResultEntity();
                itemResultEntity.setTestName("MC1_DDR2_A00");
                String valueAndUnit = s[1].trim();
                String unit = valueAndUnit.replaceAll(unitRule, "");
                String value = valueAndUnit.replaceAll(valueRule, "");
                itemResultEntity.setTestValue(value);
                itemResultEntity.setTestUnit(unit);
                itemResultEntities.add(itemResultEntity);
            } else if (StringUtils.contains(item, "MC0_DDR2_A00") && StringUtils.contains(item, "TIME")) {
                String[] s = item.split("TIME");
                ItemResultEntity itemResultEntity = new ItemResultEntity();
                itemResultEntity.setTestName("MC0_DDR2_A00");
                String valueAndUnit = s[1].trim();
                String unit = valueAndUnit.replaceAll(unitRule, "");
                String value = valueAndUnit.replaceAll(valueRule, "");
                itemResultEntity.setTestValue(value);
                itemResultEntity.setTestUnit(unit);
                itemResultEntities.add(itemResultEntity);
            }
        });
        TestResultEntity testResultEntity = new TestResultEntity();
        LinkedList<ItemResultEntity> itemResultEntitiesFirst = new LinkedList<>();// 第二部分,不去重28 +9=37

        hashMap.forEach((k, v) -> {
            ItemResultEntity itemResultEntity = new ItemResultEntity();
            itemResultEntity.setTestName(k);
            itemResultEntity.setTestValue(v);
            itemResultEntitiesFirst.add(itemResultEntity);
        });
        itemResultEntitiesFirst.addAll(itemResultEntities);
        // fileName
        LinkedHashMap<String, LinkedList<ItemResultEntity>> objectObjectLinkedHashMap = new LinkedHashMap<>();
        objectObjectLinkedHashMap.put(fileName, itemResultEntitiesFirst);
        testResultEntity.setTestData(objectObjectLinkedHashMap);
        allList.add(testResultEntity);
    }
}
